package com.diaohw.platform.remote.log;

import com.diaohw.platform.common.LogProcessAPI;
import com.diaohw.platform.common.obj.log.DbLog;
import com.diaohw.platform.common.obj.log.RequestLog;
import com.diaohw.platform.framework.rabbit.RabbitMQUService;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Hello world!
 */
@Service
public class MqLogProcess implements LogProcessAPI {

    private static final ExecutorService executor = Executors.newCachedThreadPool();
    @Resource

    RabbitMQUService rabbitMQUService;

    @PostConstruct
    public void init() {


    }

    @Override
    public void http(RequestLog requestLog) {
        executor.execute(() -> {
            rabbitMQUService.sendMessage("", requestLog);
        });
    }

    @Override
    public void db(DbLog dbLog) {
        executor.execute(() -> {
//            rabbitMQUService.sendMessage("", requestLog);
        });

    }

}
